// 解决原型链继承第二个问题： 子类向超类传递参数
function SuperType(name){
  this.name = name;
  this.colors=['red','blue','green'];
}

SuperType.prototype.sayName=function(){
  console.log(this.name)
}
function SubType(name,age){
  // 借用构造函数继承
  SuperType.call(this,name);
  // 子类实例属性
  this.age=age;
}
// 原型继承
SubType.prototype=new SuperType()
SubType.prototype.constructor=SubType;
SubType.prototype.sayAag=function(){
  console.log(this.age)
}

const instance1 =new SubType('Nicholas',78);
instance1.colors.push('black');
console.log(instance1.colors)
instance1.sayAag();
instance1.sayName();

const instance2= new SubType('Greg',88);
console.log(instance2.colors)
instance2.sayAag();
instance2.sayName();
